<?php
/*
 * Smarty plugin
 * -------------------------------------------------------------
 * File:     function.ss_entry_url.php
 * Type:     function
 * Name:     ss_entry_url
 * Purpose:  Returns url from entry object
 * -------------------------------------------------------------
 */
 
function smarty_function_ss_entry_url($params, &$smarty){
	/*if(!array_key_exists('node',$params)) {
		$smarty->trigger_error("Entry node not set");
		return;
	}*/
	//ss_error::log($smarty->get_template_vars );
	$date=explode('-',(is_null($params['node']['date_pub'])?$params['node']['created_at']:$params['node']['date_pub']));
	if($params['absolute']){
		$settings=$smarty->get_template_vars('settings');
		$lang=$smarty->get_template_vars('lang');
		return ($lang.'/'.$settings['server']['appath']['entry'].'/'.$date[0].'/'.$date[1].'/'.$params['node']['slug']);
	} else {
		return $smarty->get_template_vars('context')->url($date[0].'/'.$date[1].'/'.$params['node']['slug']);
	}
}
?>